package com.pioneer.swing.controller;

import com.pioneer.swing.model.AllContainersTable;

import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.ListSelectionModel;

import java.util.List;
import java.util.ArrayList;


/**
 * Title:        Pioneer Metals
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      Pioneer Metals
 * @author Gary Chen
 * @version 1.0
 */

public class MultiLineHighlighter implements ListSelectionListener {

	private AllContainersTable allContainersTable;
	int first=-1;
	int last=-1;

    public MultiLineHighlighter(AllContainersTable allContainersTable) {
		this.allContainersTable=allContainersTable;
    }
    public void valueChanged(ListSelectionEvent e) {

		/*ListSelectionModel listSelectionModel=(ListSelectionModel)e.getSource();

		int firstSelected=e.getFirstIndex();
		System.out.println("First selected index "+firstSelected);

		int lastSelected=e.getLastIndex();
		System.out.println("Last selected index "+lastSelected);

		int indexToUse=-1;

		if (first==-1) indexToUse=firstSelected;
		else {
			if (firstSelected<=first) indexToUse=firstSelected;
			else if (lastSelected>=last) indexToUse=lastSelected;
			else indexToUse=firstSelected;
		}

		String containerIdSelected=allContainersTable.getValueAt(indexToUse,0).toString();
		System.out.println("First selected index value"+containerIdSelected);
		int totalrows=allContainersTable.getRowCount();
		List rowsFound=new ArrayList();
		for (int count=0;count<totalrows;count++) {
			String containerIdFound=allContainersTable.getValueAt(count,0).toString();
			if (containerIdSelected.equals(containerIdFound)) {
				rowsFound.add(new Integer(count));
			}
		}
		int startInterval=((Integer)rowsFound.get(0)).intValue();
		int endInterval=((Integer)rowsFound.get(rowsFound.size()-1)).intValue();
		System.out.println("Setting range from "+startInterval+" to "+endInterval);
		//listSelectionModel.setSelectionInterval(startInterval,endInterval);
		//System.out.println(e.getSource().getClass().getName()+"Generated a selection")






		dsdfd;
*/
    }
}